package ro.ubbcluj.cs.bibliospringee.api.assembler;

import ro.ubbcluj.cs.bibliospringee.backend.model.Author;
import ro.ubbcluj.cs.bibliospringee.common.dto.AuthorDto;

public class AuthorAssembler implements Assembler<Author, AuthorDto>
{
    @Override
    public Author createModel()
    {
        return new Author();
    }

    @Override
    public AuthorDto createDto()
    {
        return new AuthorDto(Author.class.getName());
    }

    @Override
    public AuthorDto modelToDto(Author model)
    {
        final AuthorDto dto = createDto();

        dto.setId(model.getId());
        dto.setFirstName(model.getFirstName());
        dto.setLastName(model.getLastName());

        return dto;
    }

    @Override
    public Author dtoToModel(AuthorDto dto)
    {
        final Author model = createModel();
        model.setId(dto.getId());
        model.setFirstName(dto.getFirstName());
        model.setLastName(dto.getLastName());

        return model;
    }
}
